package kr.hkit.powerjava.chapter21;

import java.io.*;

public class FileError {
	private int[] list;
	private static final int SIZE = 10;
	
	public FileError() throws ArithmeticException, IOException { //생성자에 붙음..
		list = new int [SIZE];
		for(int i = 0 ; i<SIZE; i++){
			list[i] = i;
			writeList();
		}
	}

	private void writeList() throws IOException, ArithmeticException {
		PrintWriter out = null;
		
			out = new PrintWriter(new FileWriter("outfile.txt"));
			for(int i = 0 ; i<SIZE; i++){
				out.println("배열의 원소 " + i + "=" + list[i]);
			}

	}
	
	public static void main(String[] args) {
		try {
			new FileError();
		} catch (ArithmeticException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} //JVM이 처리
	}
}
